﻿<Window x:Class="WIAssistant.Main"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:loc="clr-namespace:WIAssistant"
    xmlns:Client="clr-namespace:Microsoft.TeamFoundation.WorkItemTracking.Client;assembly=Microsoft.TeamFoundation.WorkItemTracking.Client"
    xmlns:my="http://schemas.odyssey.com/wpf"
    xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock"
    xmlns:dot="clr-namespace:Dotway.WPF.Panels;assembly=Dotway.WPF.Panels" 
    xmlns:WIAssistant="clr-namespace:WIAssistant"
    Title="WI Assistant" Height="587" Width="1354" Name="MainForm" FontSize="14"    
    Icon="/WIAssistant;component/WIAssistant.ico">

    <!--xmlns:diagnostics="clr-namespace:System.Diagnostics;assembly=WindowsBase"  , diagnostics:PresentationTraceSources.TraceLevel=High-->

    <Window.Resources>
        <WIAssistant:DisableWorkItemConverter x:Key="DisableWorkItemConverter"/>
        <WIAssistant:WorkItemConverter x:Key="WorkItemConverter"/>
        <WIAssistant:WorkItemTypeToColorConverter x:Key="WorkItemTypeToColorConverter"/>
        <WIAssistant:IsTextPresentConverter x:Key="IsTextPresentConverter"/>
        <WIAssistant:VisibilityToBooleanConverter x:Key="VisibilityToBooleanConverter"/>
        <WIAssistant:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
        <WIAssistant:WorkItemTypeToStringConverter x:Key="WorkItemTypeToStringConverter"/>
        <WIAssistant:ProjectToNameConverter x:Key="ProjectToNameConverter"/>

        <!--Round Button-->
        <Style TargetType="{x:Type Button}" x:Key="roundButton">
            <Style.Resources>

                <!-- colors -->
                <LinearGradientBrush x:Key="roundButtonBackground" StartPoint="0,0" EndPoint="0,1">
                    <GradientStop Color="#BCD9FF" />
                    <GradientStop Color="#D3E6FF" Offset="1" />
                </LinearGradientBrush>

                <LinearGradientBrush x:Key="disabledRoundButtonBackground" StartPoint="0,0" EndPoint="0,1">
                    <GradientStop Color="#555"/>
                    <GradientStop Color="#CCC" Offset="1" />
                </LinearGradientBrush>

                <RadialGradientBrush x:Key="mouseOverRoundButtonBackground">
                    <GradientStop Color="#FFF9F7A9" Offset="0" />
                    <GradientStop Color="Yellow" Offset="0.2" />
                    <GradientStop Color="Orange" Offset="0.7" />

                    <GradientStop Color="Red" Offset="1" />
                </RadialGradientBrush>

                <LinearGradientBrush x:Key="glossShineBrush" StartPoint="0,0" EndPoint="0,1">
                    <GradientStop Color="#DDFFFFFF" Offset="0" />
                    <GradientStop Color="#33FFFFFF" Offset="1" />
                </LinearGradientBrush>

                <SolidColorBrush x:Key="roundButtonStroke" Color="#506997" />

                <SolidColorBrush x:Key="disabledRoundButtonStroke" Color="#333" />

                <DropShadowEffect x:Key="focusEffect" ShadowDepth="0" Color="#FFE393" BlurRadius="4"  />
                <DropShadowEffect x:Key="pressedEffect" ShadowDepth="0" Color="Red" BlurRadius="6"  />

            </Style.Resources>
            <Setter Property="Foreground" Value="Black" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" >
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                                <RowDefinition Height="7*" />
                                <RowDefinition Height="7*" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="5*" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Ellipse x:Name="bgEllipse" Grid.ColumnSpan="3" Grid.RowSpan="3" Fill="{StaticResource roundButtonBackground}" Stroke="{StaticResource roundButtonStroke}" />
                            <ContentPresenter Grid.RowSpan="3" Grid.ColumnSpan="3" HorizontalAlignment="Center" VerticalAlignment="Center" RecognizesAccessKey="True" />
                            <Ellipse x:Name="shine" Grid.Row="1" Grid.Column="1" Fill="{StaticResource glossShineBrush}" />
                        </Grid>

                        <ControlTemplate.Triggers>
                            <Trigger Property="IsKeyboardFocused" Value="true">
                                <Setter TargetName="bgEllipse" Property="Effect" Value="{StaticResource focusEffect}" />
                            </Trigger>
                            <Trigger Property="IsPressed" Value="true">
                                <Setter TargetName="shine" Property="Opacity" Value="0.35" />
                                <Setter TargetName="bgEllipse" Property="Effect" Value="{StaticResource pressedEffect}" />
                            </Trigger>
                            <Trigger Property="IsDefaulted" Value="true">
                                <Setter TargetName="bgEllipse" Property="StrokeThickness" Value="1.5" />
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter TargetName="bgEllipse" Property="Fill" Value="{StaticResource mouseOverRoundButtonBackground}" />
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter TargetName="bgEllipse" Property="Fill" Value="{StaticResource disabledRoundButtonBackground}" />
                                <Setter TargetName="bgEllipse" Property="Stroke" Value="{StaticResource disabledRoundButtonStroke}" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <!--Scroll Viewer that has a border-->
        <Style x:Key="BorderedScrollViewer" TargetType="ScrollViewer">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ScrollViewer}">
                        <Border Margin="10" BorderThickness="1" BorderBrush="#FF7F9DB9">
                            <ScrollViewer Name="projectsScroller" IsDeferredScrollingEnabled="False" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
                                <ContentPresenter/>
                            </ScrollViewer>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <!--Template to display a RelatedLink-->
        <DataTemplate DataType="{x:Type Client:RelatedLink}">
            <Border BorderBrush="Black" BorderThickness="1">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="60" />
                        <ColumnDefinition Width="1*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <TextBlock Text="{Binding RelatedWorkItemId}"></TextBlock>

                    <TextBlock Grid.Column="1" HorizontalAlignment="Left">
                    <TextBlock.Text>
                        <Binding Path="RelatedWorkItemId" Converter="{StaticResource WorkItemConverter}" ConverterParameter="Type"></Binding>
                    </TextBlock.Text>
                    </TextBlock>

                    <TextBlock TextWrapping="Wrap" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" >
                        <TextBlock.Text>
                            <Binding Path="RelatedWorkItemId" Converter="{StaticResource WorkItemConverter}" ConverterParameter="Title"></Binding>
                        </TextBlock.Text>
                    </TextBlock>
                </Grid>
            </Border>
        </DataTemplate>
        <!--Template to display a WorkItem for Adding a Link-->
        <DataTemplate DataType="{x:Type Client:WorkItem}">
            <Grid Loaded="PickedWorkItem_Loaded">
                <ScrollViewer ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="100" />
                            <ColumnDefinition Width="60" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Button Name="btnCreateLink" Grid.Row="0" HorizontalAlignment="Right" Width="100" Margin="0,2,0,2" Grid.Column="2" Click="CreateLinkClicked">
                            <Button.Content>Link</Button.Content>
                        </Button>

                        <Label Name="lblIDText" FontWeight="Bold">WI ID:</Label>
                        <Label Name="lblID" Margin="2" Grid.Column="1" Content="{Binding Id}"></Label>

                        <Label Name="lblTitleText" Grid.Row="1" FontWeight="Bold">WI Title:</Label>


                        <ToggleButton Grid.ColumnSpan="2" Grid.Row="1" HorizontalAlignment="Right" Width="100" Margin="0,2,0,2" Grid.Column="1" Name="btnAddLinkComment"
                                      Unchecked="btnAddLinkComment_Unchecked" Checked="btnAddLinkComment_Checked">
                            <Grid>
                                <CheckBox Content=" Comment" FlowDirection="RightToLeft" IsHitTestVisible="False" Focusable="False" 
                                          IsChecked="{Binding ElementName=txtLinkComment, Path=Text, Converter={StaticResource IsTextPresentConverter}}" 
                                          Name="chkHasComment"/>

                                <Popup PlacementTarget="{Binding ElementName=btnAddLinkComment}"  Name="popAddCommentLink" Closed="popAddCommentLink_Closed" 
                                        AllowsTransparency="True" StaysOpen="False" PopupAnimation="Fade" Opened="popAddCommentLink_Opened" >
                                    <Border BorderBrush="#FF000000" Background="LightBlue" BorderThickness="1,1,1,1" CornerRadius="8,8,8,8" Padding="5">
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="80"></ColumnDefinition>
                                                <ColumnDefinition Width="200"></ColumnDefinition>
                                            </Grid.ColumnDefinitions>
                                            <TextBlock TextWrapping="Wrap" Foreground="Black" >Enter Link Comment</TextBlock>
                                            <TextBox Grid.Column="1" Name="txtLinkComment" Text="{Binding ElementName=MainForm, Path=LinkComment, Mode=TwoWay}" Width="200" KeyDown="txtLinkComment_KeyDown"></TextBox>
                                        </Grid>
                                    </Border>
                                </Popup>
                            </Grid>
                        </ToggleButton>

                        <Border Grid.Row="2" Grid.ColumnSpan="3" BorderThickness="1"  BorderBrush="Black">
                            <TextBlock Padding="5,0,0,0" TextWrapping="WrapWithOverflow"  Name="lblTitle" Margin="2" Text="{Binding Title}"/>
                        </Border>
                        <Label Name="lblDescriptionText" Grid.ColumnSpan="3" Grid.Row="3" FontWeight="Bold">WI Description:</Label>
                        <Border Grid.Row="4" Grid.ColumnSpan="3" BorderThickness="1"  BorderBrush="Black">
                            <TextBlock Padding="5,0,0,0" TextWrapping="WrapWithOverflow"  Name="lblDescription" Margin="2" Text="{Binding Description}"/>
                        </Border>

                        <Label Name="lblLinkListText" Grid.Row="5" Grid.ColumnSpan="3" FontWeight="Bold">Current Links:</Label>

                        <ItemsControl x:Name="lstLinkList" Margin="2" Padding="0" Grid.Row="6" Grid.ColumnSpan="3" 
                             BorderThickness="1"  BorderBrush="Black" ItemsSource="{Binding Links}">
                            <ItemsControl.Background>
                                <Binding ElementName="RightSideBar" Path="Background"></Binding>
                            </ItemsControl.Background>
                        </ItemsControl>
                    </Grid>
                </ScrollViewer>

                <ContentControl Width="10" Height="10" Name="AnimationDestination"></ContentControl>
            </Grid>
        </DataTemplate>

        <!--Individual Item in a row--> 
        <DataTemplate x:Key="ColumnTemplate">
            <Border Visibility="{Binding ItemVisibility}" Name="ItemBorder" BorderBrush="Black" BorderThickness="1" CornerRadius="2" Padding="2">
                <WrapPanel>
                    <TextBlock FontStretch="ExtraCondensed" FontWeight="UltraLight"  FontStyle="Italic" Text="{Binding Name}" Visibility="{Binding Path=VisibilityOfWorkItemColumnTitles, Source={x:Static loc:MainMediator.Instance}}"/>
                    <TextBlock FontStretch="ExtraCondensed" FontWeight="UltraLight"  FontStyle="Italic"  Margin="0,0,5,0" Text=":" Visibility="{Binding Path=VisibilityOfWorkItemColumnTitles, Source={x:Static loc:MainMediator.Instance}}"/>
                    <TextBlock Text="{Binding Value}" Margin="0,0,10,0"/>
                </WrapPanel>
            </Border>
        </DataTemplate>

        <!--A single row in the list-->
        <DataTemplate x:Key="RowTemplate">
            <Border x:Name="ItemBorder" BorderThickness="1" BorderBrush="#D4D4FF">
                <Grid x:Name="ItemGrid" Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ItemsPresenter}}, Path=ActualWidth}" ScrollViewer.CanContentScroll="True" Margin="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="20" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="30" />
                    </Grid.ColumnDefinitions>
                    <Grid.Background>
                        <Binding Path="WorkItemForColumn.Type" Converter="{StaticResource WorkItemTypeToColorConverter}" />
                    </Grid.Background>

                    <CheckBox VerticalAlignment="Center" Grid.Column="0" IsChecked="{Binding
                                              RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBoxItem}},
                                              Mode=TwoWay, Path=IsSelected}" Name="chkIsSelected" />

                    <ItemsControl Grid.Column="1" Margin="5,0,5,0" ItemsSource="{Binding}" ItemTemplate="{StaticResource ColumnTemplate}" >
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <WrapPanel Orientation="Horizontal"></WrapPanel>
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                    </ItemsControl>

 
                    <Button HorizontalAlignment="Right" x:Name="btnPick" Grid.Column="3" Style="{StaticResource roundButton}" 
                            Width="15" Height="15" Tag="{Binding WorkItemForColumn.Id}" Margin="5,0,10,0"
                            
                            
                            Visibility="{Binding MoveModeSelected, Source={x:Static loc:MainMediator.Instance}, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=true}">
                        
                        <Path Fill="DarkBlue">
                            <Path.Data>
                                <PathGeometry>
                                    <PathFigure StartPoint="2,0" IsClosed="True">
                                        <LineSegment Point="7,5"/>
                                        <LineSegment Point="2,10"/>
                                    </PathFigure>
                                    <PathFigure StartPoint="2,2" IsClosed="True">
                                        <LineSegment Point="5,5"/>
                                        <LineSegment Point="2,8"/>
                                    </PathFigure>
                                </PathGeometry>
                            </Path.Data>
                        </Path>
                    </Button>
                </Grid>
            </Border>
        </DataTemplate>

        <!--<loc:AutoRefreshCollectionViewSource Source="{Binding loc:MainMediator.Instance.WorkItemTypeMappings}" x:Key="WorkItemTypeMappingsCollectionView">
            <loc:AutoRefreshCollectionViewSource.SortDescriptions>
                <scm:SortDescription PropertyName="SourceType" />
            </loc:AutoRefreshCollectionViewSource.SortDescriptions>
            <loc:AutoRefreshCollectionViewSource.GroupDescriptions>
                <PropertyGroupDescription PropertyName="SourceProject" Converter="{StaticResource ProjectToNameConverter}" />
            </loc:AutoRefreshCollectionViewSource.GroupDescriptions>
        </loc:AutoRefreshCollectionViewSource>-->

        <CollectionViewSource Source="{Binding WorkItemTypeMappings}" x:Key="WorkItemTypeMappingsCollectionView">
            <!--<loc:AutoRefreshCollectionViewSource.SortDescriptions>
                <scm:SortDescription PropertyName="SourceType" />
            </loc:AutoRefreshCollectionViewSource.SortDescriptions>-->
            <CollectionViewSource.GroupDescriptions>
                <PropertyGroupDescription PropertyName="SourceProject" Converter="{StaticResource ProjectToNameConverter}" />
            </CollectionViewSource.GroupDescriptions>
        </CollectionViewSource>

    </Window.Resources>
    <Grid>
        <ad:DockingManager Name="DockManager" Background="White">
            <ad:ResizingPanel  Orientation="Horizontal">
                <ad:DockablePane ad:ResizingPanel.ResizeWidth="300" Name="LeftSideBar" SelectedIndex="0">
                    <ad:DockableContent Name="Connection" Title="Connection" IsCloseable="False">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <StackPanel Margin="10" Grid.Row="0">
                                <Label>Enter Server and Project</Label>
                                <DockPanel HorizontalAlignment="Stretch">
                                    <ComboBox Margin="0,0,20,0" Name="cboServers" SelectionChanged="cboServers_SelectionChanged" Height="34.5" VerticalAlignment="Center" HorizontalAlignment="Left" Width="200" FontSize="14" />
                                    <Button Height="35" Width="50" Name="btnRefresh" VerticalAlignment="Center" HorizontalAlignment="Right"  Click="btnRefresh_Click">Reset</Button>
                                </DockPanel>
                            </StackPanel>

                            <ListBox Margin="10" BorderThickness="1" Grid.Row="1" Name="lstProjects" FontSize="14" SelectionChanged="lstProjects_SelectionChanged" MouseDoubleClick="lstProjects_MouseDoubleClick">
                            </ListBox>

                        </Grid>
                    </ad:DockableContent>
                    <ad:DockableContent Name="WIQuery" Title="WI Query" Focusable="True" IsCloseable="False">
                        <ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Hidden">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <my:OdcExpander Margin="0" Padding="1" Grid.Row="0" Header="Team Queries" HorizontalAlignment="Stretch" Name="teamQueryExpander" >
                                    <my:OdcExpander.Background>
                                        <Binding ElementName="DockManager" Path="Background"/>
                                    </my:OdcExpander.Background>
                                    <my:OdcExpander.Content>
                                        <ListBox Name="lstTeamQueries" MouseDoubleClick="lstQueries_MouseDoubleClick" />
                                    </my:OdcExpander.Content>
                                </my:OdcExpander>
                                <my:OdcExpander Margin="0" Padding="1" Grid.Row="1" Header="My Queries" HorizontalAlignment="Stretch" Name="personalQueryExpander" >
                                    <my:OdcExpander.Background>
                                        <Binding ElementName="DockManager" Path="Background"/>
                                    </my:OdcExpander.Background>
                                    <my:OdcExpander.Content>
                                        <ListBox Name="lstPersonalQueries" MouseDoubleClick="lstQueries_MouseDoubleClick" />
                                    </my:OdcExpander.Content>
                                </my:OdcExpander>
                            </Grid>
                        </ScrollViewer>
                    </ad:DockableContent>
                    
                    <!--Settings-->
                    <ad:DockableContent Name="Settings" Title="Default Fields" Focusable="True" IsCloseable="False">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                            </Grid.RowDefinitions>

                            <GroupBox Margin="0" Padding="1" Grid.Row="0" HorizontalAlignment="Stretch" Name="defaultFieldsExpander" >
                                <GroupBox.Background>
                                    <Binding ElementName="DockManager" Path="Background"/>
                                </GroupBox.Background>
                                <GroupBox.Content>
                                    <TreeView ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Visible" 
                                          ItemsSource="{Binding WITSelectorProjects}" SelectedItemChanged="SettingsWITDefaultColumn_SelectionChanged" >
                                        <TreeView.ItemTemplate>
                                            <HierarchicalDataTemplate ItemsSource="{Binding WITNodes}">
                                                <TextBlock Text="{Binding WITProjectName}" />
                                                <HierarchicalDataTemplate.ItemTemplate>
                                                    <DataTemplate>
                                                        <Border Width="200"  Margin="3" Padding="5"  CornerRadius="10" BorderBrush="Black" BorderThickness="1">
                                                            <Grid>
                                                                <Grid.RowDefinitions>
                                                                    <RowDefinition Height="Auto"/>
                                                                    <RowDefinition Height="Auto"/>
                                                                </Grid.RowDefinitions>
                                                                <TextBlock Text="{Binding WorkItemTypeName}" />
                                                                <ComboBox Grid.Row="1" SelectedItem="{Binding DefaultFieldName}" 
                                                                      ItemsSource="{Binding AllFieldsForWorkItemType}" 
                                                                      SelectionChanged="DefaultFieldForWITChosen" />
                                                            </Grid>
                                                        </Border>
                                                    </DataTemplate>
                                                </HierarchicalDataTemplate.ItemTemplate>
                                            </HierarchicalDataTemplate>
                                        </TreeView.ItemTemplate>
                                    </TreeView>
                                </GroupBox.Content>
                            </GroupBox>
                        </Grid>
                    </ad:DockableContent>
                </ad:DockablePane>


                <!--MIDDLE SECTION-->
                <ad:ResizingPanel Orientation="Vertical" MinWidth="50" MinHeight="50">
                    <ad:ResizingPanel Orientation="Horizontal" >
                        <!--Column Selector-->
                        <ad:DockablePane ad:ResizingPanel.ResizeWidth="120" >
                            <ad:DockableContent Title="Options" IsCloseable="False" HideOnClose="True">
                                <StackPanel>
                                    <CheckBox Margin="5" IsChecked="{Binding Path=VisibilityOfWorkItemColumnTitles, Converter={StaticResource VisibilityToBooleanConverter}}" >Show Titles</CheckBox>
                                    <ListBox DataContext="{Binding ColumnFields}" ItemsSource="{Binding}" SelectionMode="Multiple">
                                        <ListBox.ItemContainerStyle>
                                            <Style TargetType="ListBoxItem">
                                                <Setter Property="IsSelected" Value="{Binding IsVisible, Mode=TwoWay}"/>
                                            </Style>
                                        </ListBox.ItemContainerStyle>
                                    </ListBox>
                                </StackPanel>
                            </ad:DockableContent>
                        </ad:DockablePane>
                        <ad:DocumentPane>
                            <!--Query Results-->
                            <ad:DocumentContent Title="Query Results" IsCloseable="False">
                                <ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled" Button.Click="PickWorkItem_Click" SelectionMode="Extended" ItemTemplate="{StaticResource RowTemplate}"  Name="lstQueryResults" SelectionChanged="lstQueryResults_SelectionChanged" >
                                    <ListBox.Resources>
                                        <Style TargetType="{x:Type ListBoxItem}">
                                            <Style.Resources>
                                                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black"/>
                                                <SolidColorBrush x:Key="{x:Static SystemColors.ControlTextBrushKey}" Color="Black"/>
                                            </Style.Resources>
                                            <Style.Triggers>
                                                <DataTrigger Value="True">
                                                    <DataTrigger.Binding>
                                                        <MultiBinding Converter="{StaticResource DisableWorkItemConverter}">
                                                            <Binding ElementName="MainForm" Path="PickedWorkItemID"/>
                                                            <Binding Path="WorkItemForColumn.Id"/>
                                                        </MultiBinding>
                                                    </DataTrigger.Binding>
                                                    <Setter Property="IsEnabled" Value="False"/>
                                                    <Setter Property="loc:Main.IsCurrentItemEnabledChanged" Value="True"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </ListBox.Resources>
                                </ListBox>
                            </ad:DocumentContent>
                        </ad:DocumentPane>
                    </ad:ResizingPanel>

                    <ad:DockablePane>
                        <ad:DockableContent x:Name="WIPadDock" Title="WorkItem Pad" IsCloseable="False">
                            <ScrollViewer x:Name="WIPadCntr" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
                                <dot:ZipperPanel ChildrenPerRow="5" SpacingX="120" SpacingY="10" Name="CanvasPad"  RenderTransformOrigin="0,0"></dot:ZipperPanel>
                            </ScrollViewer>
                        </ad:DockableContent>
                    </ad:DockablePane>
                </ad:ResizingPanel>

                <!--RIGHT SECTION-->
                <ad:DockablePane MinWidth="50" MinHeight="50" ad:ResizingPanel.ResizeWidth="300"  Name="RightSideBar" SelectedIndex="1">
                    <ad:DockableContent Title="Add Links" Name="tabAddLinks" IsCloseable="False">

                    </ad:DockableContent>
                    <ad:DockableContent Selector.IsSelected="{Binding MoveModeSelected, Mode=TwoWay}" Title="Move"  Name="tabMoveWI" IsCloseable="False">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="50"/>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="50"/>
                            </Grid.RowDefinitions>
                            
                            <!--Grid to show the selection of the destination-->
                            <Grid Grid.Row="0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition></ColumnDefinition>
                                    <ColumnDefinition Width="90"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <TextBlock Grid.Column="0" TextWrapping="Wrap"  DataContext="{Binding SelectedIterationNode}" Text="{Binding IterationPath}"></TextBlock>
                                
                                <ToggleButton Grid.Column="1" HorizontalAlignment="Right" Margin="0,2,0,2" Checked="btnFindIterationChecked" Name="tglIterations" >
                                    <Grid>
                                        <CheckBox FlowDirection="RightToLeft" IsHitTestVisible="False" Focusable="False" IsChecked="{Binding SelectedIterationNode, Converter={StaticResource IsTextPresentConverter}}" Name="chkIteration">
                                            <AccessText TextAlignment="Left" TextWrapping="Wrap" Text="Select Iteration" Margin="2"/>
                                        </CheckBox>

                                        <Popup PlacementTarget="{Binding ElementName=chkIteration}"  Name="popSelectIteration" Closed="popSelectIteration_Closed"
                                        AllowsTransparency="True" StaysOpen="False" PopupAnimation="Fade">
                                            <Border BorderBrush="#FF000000" Background="LightBlue" BorderThickness="1,1,1,1" CornerRadius="8,8,8,8" Padding="5">
                                                <Grid>
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition Height="Auto"></RowDefinition>
                                                        <RowDefinition Height="300"></RowDefinition>
                                                        <RowDefinition Height="Auto"></RowDefinition>
                                                    </Grid.RowDefinitions>
                                                    <TextBlock Foreground="Black" >Select Destination:</TextBlock>
                                                    <ScrollViewer Grid.Row="1" >
                                                        <TreeView ItemsSource="{Binding IterationTree}" SelectedItemChanged="TreeView_SelectedItemChanged">
                                                            <TreeView.ItemTemplate>
                                                                <HierarchicalDataTemplate ItemsSource="{Binding Children}">
                                                                    <StackPanel Orientation="Horizontal">
                                                                        <TextBlock Text="{Binding PathEnd}" />
                                                                    </StackPanel>
                                                                </HierarchicalDataTemplate>
                                                            </TreeView.ItemTemplate>
                                                        </TreeView>
                                                    </ScrollViewer>
                                                    <Button Grid.Row="2" Background="LightBlue" Content="Clear Selection" Click="btnClear_Click"/>
                                                </Grid>
                                            </Border>
                                        </Popup>
                                    </Grid>
                                </ToggleButton>
                            </Grid>

                            <Grid Name="MappingGrid" Visibility="{Binding ShowMoveTypes}" Grid.Row="1"> 
                                <ListBox ItemsSource="{Binding Source={StaticResource WorkItemTypeMappingsCollectionView}}" HorizontalContentAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Name="lstWITypes">
                                    <ListBox.GroupStyle>
                                        <x:Static Member="GroupStyle.Default"/>
                                    </ListBox.GroupStyle>
                                    <ListBox.ItemTemplate>
                                        <DataTemplate>
                                            <Grid HorizontalAlignment="Stretch">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="2*"/>
                                                    <ColumnDefinition Width="2*"/>
                                                    <ColumnDefinition Width="50"/>
                                                </Grid.ColumnDefinitions>
                                                <TextBlock Grid.Column="0" Text="{Binding SourceType, Converter={StaticResource WorkItemTypeToStringConverter}}"/>
                                                <ComboBox Grid.Column="1" SelectedItem="{Binding DestType}" ItemsSource="{Binding WorkItemTypesForCurrentDestProject, Source={x:Static loc:MainMediator.Instance}}" DisplayMemberPath="Name" />
                                                <Button Grid.Column="2" Content="{Binding PercentMapped}" Click="ManualMappingClick"/>
                                            </Grid>
                                        </DataTemplate>                                        
                                    </ListBox.ItemTemplate>
                                </ListBox>
                            </Grid>
                            
                            <Grid Grid.Row="2">
                                <Button Command="{Binding MoveWorkItemCommand.MoveWorkItems}">Move All Work Items</Button>
                            </Grid>
                            
                        </Grid>
                    </ad:DockableContent>
                </ad:DockablePane>
            </ad:ResizingPanel>
        </ad:DockingManager>

        <Grid Name="WaitCursor" Width="300" Height="100" Visibility="Hidden" >
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Viewbox  >
                <Grid>
                    <Canvas Width="80" Height="80" Name="canvas">
                        <Canvas.RenderTransform>
                            <RotateTransform Angle="0" CenterX="40" CenterY="40" />
                        </Canvas.RenderTransform>
                        <Canvas.Triggers>

                            <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                                <EventTrigger.Actions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation  Storyboard.TargetName="canvas" 
                                                      Storyboard.TargetProperty="(Canvas.RenderTransform).(RotateTransform.Angle)" 
                                                      To="360" 
                                                      Duration="0:0:1.2" 
                                                      RepeatBehavior="Forever" />
                                        </Storyboard>

                                    </BeginStoryboard>
                                </EventTrigger.Actions>
                            </EventTrigger>
                        </Canvas.Triggers>
                        <Ellipse Canvas.Top="0" Canvas.Left="30" Width="20" Height="20" >
                            <Ellipse.Fill>
                                <SolidColorBrush>
                                    <SolidColorBrush.Color>
                                        <Color A="10" R="0" G="0" B="255" />
                                    </SolidColorBrush.Color>
                                </SolidColorBrush>
                            </Ellipse.Fill>
                        </Ellipse>
                        <Ellipse Canvas.Top="10" Canvas.Left="50" Width="20" Height="20" Fill="#15000000"/>

                        <Ellipse Canvas.Top="30" Canvas.Left="60" Width="20" Height="20" Fill="#38000000"/>
                        <Ellipse Canvas.Top="50" Canvas.Left="50" Width="20" Height="20" Fill="#55000000"/>
                        <Ellipse Canvas.Top="60" Canvas.Left="30" Width="20" Height="20" Fill="#88000000"/>
                        <Ellipse Canvas.Top="50" Canvas.Left="10" Width="20" Height="20" Fill="#aa000000"/>
                        <Ellipse Canvas.Top="30" Canvas.Left="0" Width="20" Height="20" Fill="#cc000000"/>
                        <Ellipse Canvas.Top="10" Canvas.Left="10" Width="20" Height="20" Fill="#ff000000"/>


                    </Canvas>

                    </Grid>
            </Viewbox>
            <TextBlock Grid.Row="1" Name="WaitCursorText" TextWrapping="Wrap" Visibility="Hidden" 
                       HorizontalAlignment="Center" VerticalAlignment="Center" >Moving </TextBlock>

        </Grid>
        
    </Grid>
</Window>




